package com.ict.ms.trackPlayBack.service.redis.test;

import com.ict.ms.trackPlayBack.facade.redis.dao.IUserTestDao;
import com.ict.ms.trackPlayBack.facade.redis.pojo.UserTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserTestMain {

    public static void main(String[] args) {
        ApplicationContext ac =  new ClassPathXmlApplicationContext("classpath:/applicationContext3.xml");
        IUserTestDao userDao = (IUserTestDao)ac.getBean("userDAO");
        String uid = "u123456";
        String address1 = "上海";
        UserTest userTest = new UserTest();
        userTest.setAddress(address1);
        userTest.setUid(uid);
        userDao.save(userTest);

        // ---------------Read ---------------
        userTest = userDao.read(uid);
        System.out.println(userTest);

        // --------------Update ------------
        String address2 = "北京";
        userTest.setAddress(address2);
        userDao.save(userTest);

        userTest = userDao.read(uid);
        System.out.println(userTest);

        // --------------Delete ------------
        userDao.delete(uid);
        userTest = userDao.read(uid);
        System.out.println(userTest);
    }
}
